package com.pinfly.common.crypto;

import java.security.Key;

import org.apache.log4j.Logger;

/**
 * This class extends the AESEncryption class to provide an implementation that
 * retrieves its Key from the ICryptoKey interface. This Key can come from a
 * keystore file or a perhaps some other Key provider.
 */
public class AESKeyStoreEncryption extends AESEncryption implements ICrypto
{
    private static final Logger logger = Logger.getLogger (AESKeyStoreEncryption.class);

    private ICryptoKey m_cryptoKey = null;

    public AESKeyStoreEncryption () throws CryptoException
    {
        try
        {
            m_cryptoKey = new CryptoKeyFromKeyStore ();
        }
        catch (Exception e)
        {
            logger.warn (e.getMessage ());
            throw new CryptoException (e);
        }
    }

    public Key getKey ()
    {
        return m_cryptoKey.getKey ();
    }

}
